package cn.xopencode.appletweb.controller.passport;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.oss.rpc.sms.UserSmsCodeRpc;
import cn.xopencode.oss.rpc.sms.dto.UserSendSmsCodeReqDTO;
import cn.xopencode.oss.rpc.sms.dto.UserVerifySmsCodeReqDTO;
import cn.xopencode.security.annotations.RequiresNone;
import cn.xopencode.security.annotations.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
@Api(tags = "用户短信验证码 API")
@RestController
@RequestMapping("/smscode")
public class UserSmsCodeController {
    @DubboReference(version = "${dubbo.consumer.UserSmsCodeRpc.version}")
    private UserSmsCodeRpc userSmsCodeRpc;
    @PostMapping("/sendsmscode")
    @ApiOperation("发送手机验证码")
    @RequiresNone
    //@RequiresPermissions("user:admin:add")
   public CommonResult<Boolean> sendSmsCode(@Valid UserSendSmsCodeReqDTO sendSmsCodeDTO) {
        return userSmsCodeRpc.sendSmsCode(sendSmsCodeDTO);
    }
    @PostMapping("/verifysmscode")
    @ApiOperation("验证手机验证码")
    @RequiresNone
   public CommonResult<Boolean> verifySmsCode(@Valid UserVerifySmsCodeReqDTO verifySmsCodeDTO){
        return userSmsCodeRpc.verifySmsCode(verifySmsCodeDTO);
    }
}
